package coneccion;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.util.Properties;

public class Coneccion {
    
    private Connection con;
    private Statement st;

    public Connection getCon() {
        return con;
    }


    public Statement getSt() {
        return st;
    }

    public void setSt(Statement st) {
        this.st = st;
    }



    public Statement connect() //regresa un objeto statement
    {
        con =null;
        st=null;
        try
         {
             Class.forName("com.mysql.jdbc.Driver").newInstance();
             Properties prop=new Properties();
             prop.setProperty("user", "root");
             prop.setProperty("password", "123");
             con=DriverManager.getConnection("jdbc:mysql://localhost:3306/interview_system",prop);
             st=con.createStatement();
             
         }catch(Exception ex)
         {
             System.out.println(ex.toString());
         }
        return st;
    }

       public PreparedStatement connect(String sql) //regresa un objeto statement
    {
        con =null;
        st=null;
        PreparedStatement ps=null;
        try
         {
             Class.forName("com.mysql.jdbc.Driver").newInstance();
             Properties prop=new Properties();
             prop.setProperty("user", "root");
             prop.setProperty("password", "123");
             con=DriverManager.getConnection("jdbc:mysql://localhost:3306/interview_system",prop);
             st=con.createStatement();
             ps=con.prepareStatement(sql);
         }catch(Exception ex)
         {

         }
        return ps;
    }

    public Statement connect(String us, String ps) //regresa un objeto statement y recibe parametros usuario pass
    {
        con =null;
        st=null;
        try
         {
             Properties prop=new Properties();
             prop.setProperty("user", us);
             prop.setProperty("password", ps);
             con=DriverManager.getConnection("jdbc:mysql://localhost:3306/interview_system",prop);
             st=con.createStatement();

         }catch(Exception ex)
         {

         }
        return st;
    }


}
